package com.cloudcc.mobile.view.crop;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;

import com.cloudcc.mobile.R;
import com.cloudcc.mobile.view.base.BaseActivity;

/**
 * @Description: 显示 选择图片 获取类型 取消 拍照
 * @author wangzhiqiang
 * @date 2016-1-20 下午12:47:32
 * 
 */
public class ShowSelectPictureModeActivity extends BaseActivity implements
		OnClickListener {

	private LinearLayout dialogLayout;
	private Button takePhotoBtn;
	private Button pickPhotoBtn;
	private Button cancelBtn;

	@Override
	public void init(Bundle savedInstanceState) {
		super.init(savedInstanceState);
		dialogLayout = (LinearLayout) findViewById(R.id.dialog_layout);
		takePhotoBtn = (Button) findViewById(R.id.btn_take_photo);
		pickPhotoBtn = (Button) findViewById(R.id.btn_pick_photo);
		cancelBtn = (Button) findViewById(R.id.btn_cancel);
		dialogLayout.setOnClickListener(this);
		takePhotoBtn.setOnClickListener(this);
		pickPhotoBtn.setOnClickListener(this);
		cancelBtn.setOnClickListener(this);

	}

	@Override
	public int getLayoutId() {
		return R.layout.add_pic_layout;
	}

	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.btn_take_photo:
			takePhoto();
			break;
		case R.id.btn_pick_photo:
			pickPhoto();
			break;
		default:
			finish();
			break;
		}
	}

	/**
	 * 拍照获取图片
	 */
	private void takePhoto() {
		Intent intent = new Intent();
		intent.putExtra(ICrop.PIC_OB_MODEL, ICrop.SELECT_PIC_BY_TACK_PHOTO);
		setResult(Activity.RESULT_OK, intent);
		finish();
	}

	/***
	 * 从相册中取图片
	 */
	private void pickPhoto() {
		Intent intent = new Intent();
		intent.putExtra(ICrop.PIC_OB_MODEL, ICrop.SELECT_PIC_BY_PICK_PHOTO);
		setResult(Activity.RESULT_OK, intent);
		finish();
	}

}
